<template>
  <div class="comment-reply">
    <van-nav-bar :title="`${comment.reply_count}条回复`">
      <van-icon slot="left" name="cross" class="close" @click="$emit('close')"></van-icon>
    </van-nav-bar>
    <comment-item :comment="comment"/>
    <van-cell title="所有回复"></van-cell>
    <comment-list :source="comment.com_id" :list="commentList" type="c"/>
    <div class="article-bottom">
      <van-button class="comment-btn" type="default" round size="small" @click="isPostShow=true">发布回复</van-button>
    </div>
    <van-popup
        v-model="isPostShow"
        position="bottom"
    >
      <post-comment
          :target="comment.com_id"
          :article-id="articleId"
          @post-success="onPostSuccess"/>
    </van-popup>
  </div>
</template>

<script>
import commentItem from "@/views/article/components/commentItem";
import commentList from "@/views/article/components/commentList";
import postComment from "@/views/article/components/postComment";
export default {
  name: "commentReply",
  components:{
    commentItem,
    commentList,
    postComment
  },
  data(){
    return{
      isPostShow:false,
      commentList:[]
    }
  },
  props:{
    comment:{
      type:Object,
      required:true
    },
    articleId:{
      type:[Number,String,Object],
      required:true
    }
  },
  methods:{
    onPostSuccess(comment){
      this.commentList.unshift(comment)
      this.comment.reply_count++
      this.isPostShow=false
    }
  }
}
</script>

<style scoped lang="less">
/deep/.van-nav-bar__title{
  color: #000000 !important;
}
.close{
  color: #000000 !important;
  font-size: 20px;
}
.article-bottom{
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  box-shadow:0px 0px 1px #000;
  background-color: #ffffff;
  display: flex;
  justify-content: space-around;
  align-items: center;
  font-size: 22px;
  .comment-btn{
    width: 200px;
    background-color:#f7f8fa;
  }
}
</style>